package router

import (
	"github.com/gin-gonic/gin"
	"sys-admin/app/api"
)

func InitRouter() *gin.Engine {
	r := gin.New()
	r.Use(gin.Logger())
	r.Use(gin.Recovery())

	apiV1 := r.Group("/v1/app")

	userGroup := apiV1.Group("/user")
	{
		userGroup.GET("/list", api.UserCtl.List)
		userGroup.POST("/add", api.UserCtl.Add)
		userGroup.PUT("/update", api.UserCtl.Update)
		userGroup.DELETE("/delete", api.UserCtl.Delete)
	}

	roleGroup := apiV1.Group("/role")
	{
		roleGroup.POST("/add", api.RoleCtl.Add)
		roleGroup.GET("/list", api.RoleCtl.List)
		roleGroup.PUT("/update", api.RoleCtl.Update)
		roleGroup.DELETE("/delete", api.RoleCtl.Delete)
	}

	menuGroup := apiV1.Group("/menu")
	{
		menuGroup.GET("/list", api.MenuCtl.List)
		menuGroup.POST("/add", api.MenuCtl.Add)
		menuGroup.PUT("/update", api.MenuCtl.Update)
		menuGroup.DELETE("/delete", api.MenuCtl.Delete)
	}

	logGroup := apiV1.Group("/log")
	{
		logGroup.GET("/list", api.LogCtl.List)
		logGroup.POST("/add", api.LogCtl.Add)
		logGroup.PUT("/update", api.LogCtl.Update)
		logGroup.DELETE("/delete", api.LogCtl.Delete)
	}

	return r
}
